package dao;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

import model.Customer;

public class BeanPropertyRowMapperTest extends JdbcDaoSupport {

	public static void main(String[] args) {
		ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		BeanPropertyRowMapperTest springMapperDao = (BeanPropertyRowMapperTest) ctx.getBean("springMapperDao");
		springMapperDao.getListMapper();
	}
	
	public void getListMapper(){
		String sql = "SELECT * FROM CUSTOMER";
		List<Customer> customers  = getJdbcTemplate().query(sql, new BeanPropertyRowMapper(Customer.class));
		for(Customer cust: customers) {
			System.out.println(cust.toString());
		}
	}
}
